Skip to content

Classify premium_daily and drop wait-time words from limit_type - #107

Draft
makegov-hal[bot] wants to merge 2 commits into
mainfrom
fix/rate-limit-type-daily
Draft

makegov-hal[bot] wants to merge 2 commits into
mainfrom
fix/rate-limit-type-daily

Conversation

@makegov-hal

@makegov-hal makegov-hal Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Closes #108

What

Tightens TangoRateLimitError.limit_type in tango/exceptions.py:

  • When the detail names the rate (Rate limit exceeded for <name>.), the name maps exactly: daily → "daily", burst → "burst", premium_daily → "premium_daily". A name the SDK doesn't recognize returns None.
  • When the detail names no rate, the fallback matches only the whole words "daily" and "burst". The "minute" and "day" heuristics are gone.
  • The docstring lists all three values.

Why

The headline bug (a daily 429 whose wait reads "9 hours, 14 minutes, 3 seconds" coming back as burst) was already fixed in 1.18.2. Two holes were left:

  • premium_daily came back as daily. The code substring-matched "daily" inside the rate name, so a per-feature cap (currently the CALC labor-rate endpoints) was indistinguishable from the account-wide daily lockout. The two need different handling: one blocks a single endpoint, the other blocks everything.
  • The fallback still guessed from the wait time. With no exceeded for in the detail, "minute" meant burst and "day" meant daily, and those words show up in the wait text (Expected available in 3 minutes.).

The rate names come from the API's DEFAULT_THROTTLE_RATES (daily, burst) and PREMIUM_QUERY_DEFAULT_RATES (premium_daily), and the detail strings from api/throttles.py.

Testing

  • uv run pytest: 677 passed, 31 skipped.
  • Extended test_limit_type_reads_the_rate_name_not_the_wait with a daily detail carrying hours, minutes, and seconds, a burst detail, a premium_daily detail, the team-pooled daily detail (with the "shared by everyone on your team" sentence appended), and an unrecognized rate name.
  • Added test_limit_type_without_a_rate_name_matches_only_the_words_daily_and_burst for the fallback. Against the old code, the premium_daily, "3 minutes", and "1 day" cases fail.
  • ruff check and ruff format --check pass on the changed files.

No version bump.

🤖 Generated with Claude Code

infinityplusone and others added 2 commits November 16, 2026 10:42
limit_type read the rate name from "exceeded for <name>" but then
substring-matched "daily" in it, so a per-feature premium_daily cap came
back as "daily". The no-match fallback still treated "minute" as burst and
"day" as daily, words that appear in the wait text itself.

Map the rate name exactly (daily, burst, premium_daily; anything else is
None), and have the fallback match only the whole words "daily" and
"burst".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YNPQk6UN72ZCQV9Ck6kfu8
Single backticks in the docstring, wrapped under 150 chars, and the
CHANGELOG fix collapsed to one bullet.

Refs #108

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YNPQk6UN72ZCQV9Ck6kfu8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TangoRateLimitError.limit_type reports premium_daily 429s as "daily" and classifies by wait-time words

1 participant